﻿/////////////////////////////////////////////////////////////////
//
// Silverlight 5: 3D Physics using Balder and Jiglibx
// by Andy Beaulieu - http://www.andybeaulieu.com
//
// LICENSE: This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ANY 
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS
// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
/////////////////////////////////////////////////////////////////

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace Spritehand.Physics3D
{
    
    public class InputManager
    {
        static List<Key> _keysDown = new List<Key>();

       

        public static bool IsKeyDown(Key key)
        {
            return _keysDown.IndexOf(key) >= 0;
        }

        public static bool IsUpDown { get; set; }
        public static bool IsLeftDown { get; set; }
        public static bool IsRightDown { get; set; }
        public static bool IsDownDown { get; set; }
        public static bool IsStrafeLeftDown { get; set; }
        public static bool IsStrafeRightDown { get; set; }

        public static void HandleKey(Key key, bool value)
        {
            if (value == true)
            {
                // add the key to the list of down keys
                if (_keysDown.IndexOf(key) < 0)
                {
                    _keysDown.Add(key);
                }
            }
            else
            {
                // remove the key to the list of down keys
                if (_keysDown.IndexOf(key) >= 0)
                {
                    _keysDown.Remove(key);
                }

            }

            switch (key)
            {
                case Key.W:
                    InputManager.IsUpDown = value;
                    break;
                case Key.S:
                    InputManager.IsDownDown = value;
                    break;
                case Key.A:
                    InputManager.IsStrafeLeftDown = value;
                    break;
                case Key.D:
                    InputManager.IsStrafeRightDown = value;
                    break;
                case Key.Right:
                    InputManager.IsRightDown = value;
                    break;
                case Key.Left:
                    InputManager.IsLeftDown = value;
                    break;
            }
        }
    }

}
